package com.jonyxu.xjojo.generator.controller;

import com.jonyxu.xjojo.common.utils.ResultUtil;
import com.jonyxu.xjojo.common.vo.Result;
import com.jonyxu.xjojo.generator.entity.TableInfo;
import com.jonyxu.xjojo.generator.service.IGenService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Slf4j
@Controller
@RequestMapping("/tool/gen")
public class GeneratorController{

    private String prefix = "tool/gen";

    @Autowired
    private IGenService genService;

    @GetMapping()
    public String gen()
    {
        return prefix + "/gen";
    }

    @PostMapping("/list")
    @ResponseBody
    public Result<List<TableInfo>> list(TableInfo tableInfo)
    {
        List<TableInfo> list = genService.selectTableList(tableInfo);
        return new ResultUtil<List<TableInfo>>().setData(list);
    }
}
